package framework.util.aopLog.controller;

import framework.bo.SysRole;
import framework.common.ResponseVo;
import framework.util.aopLog.bo.SysMethodLog;
import framework.util.aopLog.service.SysMethodExceptionLogService;
import framework.util.aopLog.service.SysMethodLogService;
import framework.util.queryFilter.service.impl.QueryFilter;
import frameworkExt.util.controller.BaseControllerExt;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 陈建宁 on 2019/6/24 0024 下午 5:44
 */
@Controller
@RequestMapping("/framework/sysMethodLog.do")
public class SysMethodLogController extends BaseControllerExt {

    @Resource
    private SysMethodLogService service;
    @Resource
    private SysMethodExceptionLogService sysMethodExceptionLogService;

    @ResponseBody
    @RequestMapping(params = "method=list")
    public ResponseVo list(ModelAndView model, HttpServletRequest request, HttpServletResponse response){
        QueryFilter filter = new QueryFilter(request, true);
        List<SysMethodLog> list = service.getAll(filter);
        return sendSuccess(list, filter.getPageBean().getTotals());
    }

    @ResponseBody
    @RequestMapping(params = "method=delete")
    public ResponseVo delete(ModelAndView model, HttpServletRequest request, HttpServletResponse response){
        String lid = request.getParameter("lid");
        if (StringUtils.isBlank(lid)) {
            return sendFail("参数错误");
        }
        service.removeById(Integer.valueOf(lid));
        return sendSuccess();
    }



}
